package PTAyichang;

import java.util.Arrays;
import java.util.Scanner;

public class Pta03 {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n= sc.nextInt();
        double [] arr = new double[n];
        for (int i=0;i<arr.length;i++){
            arr[i]=sc.nextDouble();
        }
        while (sc.hasNext()){
            try {
                System.out.println(ArrayUtils.findMax(arr, sc.nextInt(),sc.nextInt()));
            } catch (Exception e) {
                System.out.println(e.toString());
            }
            try {
                System.out.println("//这里是标识信息");
            } catch (Exception e1) {
            }
            sc.close();
        }
    }

}
class ArrayUtils{
    public static double findMax(double[] arr, int begin, int end) throws IllegalAccessException {
        if (!(begin<end)) throw new IllegalArgumentException("begin:"+begin+" >= end:"+end);
        else if (!(begin>=0)) throw new IllegalAccessException("begin:"+begin+" < 0");
        else if (!(end<arr.length)) throw new IllegalAccessException("begin:"+begin+" > arr.length");
        double max=0;
        for (int i=begin;i<end;i++){
          max = Math.max(arr[i], max);
        }
        return max;
    }

}